﻿$(function () {
    $('#btnSearch').click(function () {
        search();
    });
    $('#btnSearch').click().focus();
    $('#btnAdd').click(function () {
        edit(0);
    });
});
function search(pageNumber) {
    var queryData = {
        Name: $("#txtPathWayName").val()
    }
    initTable(queryData, 1);
}
function initTable(queryData, pageNumber) {
    $("#maingrid").ligerGrid({
        height: '100%',
        url: '/PathwayList/Search?ram=' + new Date().getMilliseconds(),
        parms: queryData,
        page: pageNumber,
        pageSize: 30,
        rownumbers: false,
        heightDiff: -5,
        columns: [
            { display: 'ID', name: 'ID', maxWidth: 100 },
        {
            display: '路径名称', name: 'Name', render: function (row) {
                var html = '<a href="../PathWaySet?Id=' + row.ID + '">' + row.Name + '</a>';
                return html;
            }
        },
        { display: '排序', name: 'Sort', maxWidth: 100 },
        { display: '等级', name: 'Level', maxWidth: 100 },
        {
            display: '创建时间', name: 'CreateTime', render: function (row) {
                return obj2Timemm(row.CreateTime);
            }
        },
        {
            display: '操作', name: 'Name', render: function (row) {
                var html = '';
                html += "<a href=\"JavaScript:EditContent(" + row.ID + ")" + "\">" + "诊疗内容" + "<\/a>"
                html += "&nbsp;&nbsp;&nbsp;&nbsp;";
                html += '<a href="javascript:edit(' + row.ID + ')">' + "编辑" + '</a>';
                return html;
            }
        }
        ]
    });
}

//添加/编辑
function edit(id) {
    var tit = (id > 0) ? "编辑路径" : "添加路径";
    $.ligerDialog.open({
        height: 200,
        width: 450,
        title: tit,
        data: { Id: id },
        url: '/StrokeCenter/PathwayList/Edit?id=' + id,
        showMax: false,
        showToggle: false,
        showMin: false,
        isResize: false,
        slide: false,
        buttons: [{
            text: '回调函数', onclick: function (i, d) {
                $("#btnSearch").click();
            }
        }],
        cls: "closeCls"
    });
    $(".l-dialog-buttons").hide();
}
$(document).on("click", ".closeCls", function () {
    $("#btnSearch").click();
});

function EditContent(id) {
    $.ligerDialog.open({
        height: 780,
        width: 1000,
        title: '添加诊疗内容',
        data: { Id: id },
        url: '/StrokeCenter/PathwaySet/EditContent?pathId=' + id,
        showMax: false,
        showToggle: false,
        showMin: false,
        isResize: false,
        slide: false,
        buttons: [{
            text: '回调函数', onclick: function (i, d) {
                $("#btnSearch").click();
            }
        }],
        cls: "closeCls"
    });
    $(".l-dialog-buttons").hide();
}